package com.dao.green.cn.applibary.adapters.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * Created by Ant on 2017/7/27  20:01
 * <p>
 * <p>
 *
 * @version 1.0.0
 * @auther Ant
 */

public abstract class MyBaseAdapter<T> extends BaseAdapter {

    protected Context context;
    protected LayoutInflater inflater;

    protected List<T> data;

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
        this.notifyDataSetChanged();
    }

    public MyBaseAdapter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return data == null ? 0 : data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}
